package com.itheima.controller;

import com.itheima.health.entity.Result;
import com.itheima.health.service.ReportService;
import com.itheima.health.service.UserService;
import com.itheima.health.vo.MenuVO;
import io.swagger.annotations.Api;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@Api(tags = "报表管理开发")  // 作用在类上
@RequestMapping("report")
public class ReportController {

    @Reference
    private ReportService reportService;

    @Reference
    private UserService userService;

    @GetMapping("memberReportByDate/{dateValue}")
    public Result memberReportByDate(@PathVariable("dateValue") String[] dateValue) {
        return new Result(reportService.memberReportByDate(dateValue));
    }

    @GetMapping("findMemberSex")
    public Result findMemberSex() {
        return new Result(reportService.findMemberSex());
    }

    @GetMapping("findMemberAge")
    public Result findMemberAge() {
        return new Result(reportService.findMemberAge());
    }

    @GetMapping("setmealProportion")
    public Result setmealProportion() {
        return new Result(reportService.setmealProportion());
    }

    /* 动态展示菜单
    todoby 董子帆
    */
    @GetMapping("getMenu/{username}")
    public Result getMenu(@PathVariable("username") String name) {

        List<MenuVO> menu = userService.getMenu(name);
        return new Result(menu);

    }


    //导出excel文件 todoby dzf
    @PostMapping("exportExcel")
    public Result exportExcel(@RequestBody Map map) throws Exception {

        return new Result(reportService.exportExcel(map));
    }

    //报表数据 todoby dzf
    @GetMapping("business")
    public Result getBusinessReport() {
        return new Result(reportService.getBusinessReport());

    }

}








